package com.lagou.sale.service;

import com.lagou.sale.dao.OrderDao;
import com.lagou.sale.pojo.PayResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderService {
    @Autowired
    private OrderDao orderDao;

    public PayResult payOrder(long orderId) {
        int num = orderDao.payOrder(orderId);
        PayResult payResult = new PayResult();
        if (num == 0) {
            System.out.println("order: "+orderId+" pay failed");
            payResult.setSuccess(false);
        } else {
            System.out.println("order: "+orderId+" pay success");
            payResult.setSuccess(true);
        }
        return payResult;
    }
}
